#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    vector<int> sortArrayByParityII(vector<int> &nums)
    {
        vector<int> a, b, ret;
        for (int i = 0; i < nums.size(); ++i)
        {
            if (nums[i] % 2)
            {
                b.push_back(nums[i]);
            }
            else
            {
                a.push_back(nums[i]);
            }
        }
        for (int i = 0; i < nums.size() / 2; ++i)
        {
            ret.push_back(a[i]);
            ret.push_back(b[i]);
        }
        return ret;
    }
};